package cn.stimd.spring.context.annotation;

import cn.stimd.spring.beans.factory.config.BeanDefinition;
import org.springframework.util.ClassUtils;

import java.beans.Introspector;

/**
 * Created by Stimd
 * 项目地址：https://gitee.com/stimd/spring-wheel
 * 公众号：Java编程探微
 */
public class AnnotationBeanNameGenerator {

    public String generateBeanName(BeanDefinition definition) {
        return buildDefaultBeanName(definition);
    }


    //创建默认的名称，即类名首字母小写
    protected String buildDefaultBeanName(BeanDefinition definition){
        String beanClassName = definition.getBeanClassName();
        String shortClassName = ClassUtils.getShortName(beanClassName);
        return Introspector.decapitalize(shortClassName);
    }
}